<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <#assign base=request.contextPath  />
    <link rel="stylesheet" href="${base}/js/layui/css/layui.css?t=1534970980648" media="all">
    <script type="text/javascript" src="${base}/js/zhang.js"></script>
    <script src="${base}/js/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${base}/js/ztree/jquery-1.4.4.min.js"></script>
    <script src="${base}/js/jquery.min.js"></script>

    <style type="text/css">
        form{
            padding:20px;
        }
        .layui-btn-radius{
            border-radius: 5px;
        }
    </style>
</head>
<body>
<form action="" class="layui-form">

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">选择要删除的房间</label>
            <div class="layui-input-inline">
                <select name="city" lay-search="" lay-verify="required" id="home_user" >
                </select>
            </div>
        </div>
    </div>



    <div class="layui-form-item">

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-radius" lay-submit="" onclick="delHome()" type="button" lay-filter=""style="background-color: #0092EF;">立即删除</button>
<#--
                <button type="reset" class="layui-btn layui-btn-primary layui-btn-radius">重置</button>
-->
            </div>
        </div>
    </div>
</form>

<script>

    findUserAll()
    layui.use(['form', 'layedit'], function(){
        var form = layui.form
                ,layer = layui.layer
                ,layedit = layui.layedit

    });






    //查询所有用户
    function findUserAll(){
        $.ajax({
            type:"POST",
            url:"${base}/room/findAllRoom",
            async:false,
            success : function(data){
                for(var i=0;i<data.length;i++){
                    $("#home_user").append(
                            '<option value="'+data[i].id+'">'+data[i].name+'</option>'
                    )
                }
            }
        });

    }

    function delHome(){
        if(!isNull()){
            return;
        }
        var requstData={};

        requstData.roomId=$("#home_user option:selected").val();
        $.ajax({
            type:"POST",
            url:"${base}/room/delete",
            data:{"id":requstData.roomId},
            success : function(data) {



                if (data === "true") {

                    layer.msg("删除成功")
                    setTimeout(function(){
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                        parent.initHome();
                    },500)



                } else {
                    layer.msg(data);
                }
            }
        });
    }
</script>
</body>

</html>
